package echat.future.cn.echat.my.view;

import echat.future.cn.echat.R;
import echat.future.cn.echat.databinding.ActivityAnotherQuestoonBinding;
import echat.future.cn.echat.my.api.UserApi;
import echat.future.cn.echat.my.form.AnotherForm;
import echat.future.cn.echat.my.utils.HttpUtilsRequst;
import echat.future.cn.echat.my.utils.PhoneUtils;
import echat.future.cn.echat.my.utils.UserHelper;
import echat.future.cn.echat.my.weight.Navagation.AdapterNavagation;
import echat.future.cn.echat.my.weight.Navagation.IBaseNavagation;
import okhttp3.MediaType;
import okhttp3.RequestBody;

public class AnotherQuestoonActivity extends BaseActivity<ActivityAnotherQuestoonBinding> {

    @Override
    public int layoutId() {
        return R.layout.activity_another_questoon;
    }

    @Override
    public IBaseNavagation navagation() {
        return new AdapterNavagation(this).setTitle("其他问题", 16, R.color.white).setBack(R.drawable.btn_back).setNavagationBackgroudColor(R.color.color_161823);
    }

    @Override
    public void initView() {
        bind.submit.setOnClickListener(v -> submit());
    }


    private void submit(){
        if(bind.suggest.getText().toString().equals("")){
            toast("请输入建议");
            return;
        }
        RequestBody username = RequestBody.create(MediaType.parse("multipart/form-data"),UserHelper.getUserId());
        RequestBody con = RequestBody.create(MediaType.parse("multipart/form-data"),bind.suggest.getText().toString());
        RequestBody phone = RequestBody.create(MediaType.parse("multipart/form-data"),bind.phone.getText().toString());

        new HttpUtilsRequst<String>(this,HttpUtilsRequst.retrofitClient.create(UserApi.class).
                addproblem(username,con,phone))
                .setmOnRequstSuccessListener((HttpUtilsRequst.OnRequstSuccessListener<String>) string -> {
                    toast("提交问题成功");
                    finish();
                })
                .start();
    }
}
